﻿using _10Net8AspNetCore_WebApi.Model;
using Microsoft.AspNetCore.Mvc;

namespace _10Net8AspNetCore_WebApi.Controller
{
    [ApiController]
    [Route("Student")]
    public class StudentController
    {
        public static List<Student> Students = new List<Student>();

        #region Student
        [HttpGet]
        public Student GetStudent()
        {
            return Students[0];
        }

        [HttpPost]
        public Student AddStudent()
        {
            Students.Add(new Student() { ID = 1, Name = "fufu" });
            return Students[0];
        }


        [HttpPut]
        public Student UpdateStudent()
        {
            Students.RemoveAt(0);
            Students.Add(new Student() { ID = 2, Name = "fufu2" });
            return Students[0];
        }


        [HttpDelete]
        public string DeleteStudent()
        {
            Students.RemoveAt(0);
            return "删除成功";
        }
        #endregion
    }
}
